#pragma once

#include <cmath>
using namespace std;

namespace uppg31
{
	class summera
	{
	public:

		summera()
		{
		}

		~summera()
		{
		}

		double sum_rekursiv(int x, int n)
		{
			if (n == 0)
			{
				return 1;
			}
			else
			{
				return (pow(x, n) / fak_rekursiv(n)) + sum_rekursiv(x, n - 1);
			}
		}

		int fak_rekursiv(int n)
		{
			if (n <= 1)
			{
				return 1;
			}
			else
			{
				return n * fak_rekursiv(n - 1);
			}
		}

		double sum_iterativ(int x, int n)
		{
			double sum = 0;
			for (int i = 0; i <= n; i++)
			{
				sum += pow(x, i) / fak_iterativ(i);
			}
			return sum;
		}

		int fak_iterativ(int n)
		{
			int sum = 1;
			for (int i = 1; i <= n; i++)
			{
				sum *= i;
			}
			return sum;
		}
	};
}

